package com.imesne.office.excel.validation;

import com.imesne.office.excel.exception.CellValueInvalidException;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * Created by liyd on 17/7/3.
 */
public interface CellValueValidator {

    /**
     * 是否支持校验
     *
     * @param workbook   the workbook
     * @param sheet      the sheet
     * @param sheetIndex the sheet index
     * @param row        the row
     * @param rowIndex   the row index
     * @param cellIndex  the cell index
     * @return boolean
     */
    boolean isSupportValidate(Workbook workbook, Sheet sheet, int sheetIndex, Row row, int rowIndex, int cellIndex);

    /**
     * 校验
     *
     * @param value      the value
     * @param sheetIndex the sheet index
     * @param rowIndex   the row index
     * @param cellIndex  the cell index
     * @return
     * @throws CellValueInvalidException the cell value invalid exception
     */
    void validate(Object value, int sheetIndex, int rowIndex, int cellIndex) throws CellValueInvalidException;


}
